from model import film
from model.film import Film
from model.user import User
from selenium import webdriver
from selenium.common.exceptions import *
from selenium_fixture import app


def test_add_film(app):
    app.go_to_home_page()
    app.login(User.Admin())
    assert app.is_logged_in()
    app.add_film(Film.correct_description())
    assert app.is_page_film()
    app.logout()
    assert app.is_not_logged_in()

def test_del_film(app):
    app.go_to_home_page()
    app.login(User.Admin())
    assert app.is_logged_in()
    assert app.film_is_avaliable()
    app.del_film()
    assert app.film_is_avaliable()
    app.logout()
    assert app.is_not_logged_in()

def test_search_positive(app):
    app.go_to_home_page()
    app.login(User.Admin())
    assert app.is_logged_in()
    app.search_film(Film.correct_description())
    assert app.film_is_avaliable()
    app.logout()
    assert app.is_not_logged_in()

def test_search_negative(app):
    app.go_to_home_page()
    app.login(User.Admin())
    assert app.is_logged_in()
    app.search_film(Film.incorrect_description())
    assert app.film_is_not_avaliable()
    app.logout()
    assert app.is_not_logged_in()
